﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SES.CMS.BL;
using System.Web.UI.HtmlControls;
using SES.CMS.DO;
using System.Data;

namespace SES.CMS
{
    public partial class About : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                int categoryID = int.Parse(Request.QueryString["ID"]);
                rptAboutDetailDataSource(categoryID);

                cmsCategoryDO objCategory = new cmsCategoryBL().Select(new cmsCategoryDO() { CategoryID = categoryID });
                rptOther.DataSource = new DataView(new cmsCategoryBL().SelectByParent(objCategory.ParentID), "CategoryID <>" + objCategory.CategoryID, "", DataViewRowState.CurrentRows);
                rptOther.DataBind();
                //SEO
                if (!string.IsNullOrEmpty(objCategory.MetaTag))
                {
                    HtmlMeta metaKey = new HtmlMeta();
                    metaKey.Name = "keywords";
                    metaKey.Content = objCategory.MetaTag;
                    Page.Header.Controls.Add(metaKey);
                }
                else
                { }
                HtmlMeta metaDesc = new HtmlMeta();
                metaDesc.Name = "description";
                if (!string.IsNullOrEmpty(objCategory.MetaDes))
                {
                    metaDesc.Content = objCategory.MetaDes;
                }
                else
                {
                    metaDesc.Content = objCategory.Description;
                }
                Page.Header.Controls.Add(metaDesc);

                if (!string.IsNullOrEmpty(objCategory.PageTitle))
                {
                    Page.Title = objCategory.PageTitle + " | " + Ultility.WebTitle();
                }
                else
                {
                    Page.Title = objCategory.Title + " | " + Ultility.WebTitle();
                }


            }
            else
            {
                Response.Redirect("/");
            }

        }
        private void rptAboutDetailDataSource(int categoryID)
        {
            rptAbout.DataSource = new cmsCategoryBL().SelectByPK(categoryID);
            rptAbout.DataBind();
        }
        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
    }
}